home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MultiSession 1.04 Source / Core 27⁄June⁄1993 / CEnclosure.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-12  |  6.9 KB  |  264 lines  |  [TEXT/KAHL]

  1. /* CEnclosure.c */
  2.  
  3. #include "CEnclosure.h"
  4. #include "CSack.h"
  5. #include "CWindow.h"
  6.  
  7.  
  8. /* */            CEnclosure::CEnclosure()
  9.     {
  10.         CSack*    Temp;
  11.  
  12.         Temp = new CSack;
  13.         Temp->ISack(sizeof(CViewRect*),128);
  14.         ListOfObjects = Temp;
  15.     }
  16.  
  17.  
  18. /* dispose of things */
  19. /* */            CEnclosure::~CEnclosure()
  20.     {
  21.         CViewRect*    Thang;
  22.  
  23.         ERROR(Initialized != True,PRERR(ForceAbort,
  24.             "CEnclosure::~CEnclosure called on uninitialized object."));
  25.         ListOfObjects->ResetScan();
  26.         while (ListOfObjects->GetNext(&Thang))
  27.             {
  28.                 delete Thang;
  29.                 ListOfObjects->ResetScan();
  30.             }
  31.         delete ListOfObjects;
  32.     }
  33.  
  34.  
  35. void            CEnclosure::IEnclosure(LongPoint Start, LongPoint Extent,
  36.                         CWindow* TheWindow, CEnclosure* TheEnclosure)
  37.     {
  38.         ERROR(Initialized == True,PRERR(ForceAbort,
  39.             "CEnclosure::IEnclosure called on already initialized object."));
  40.         EXECUTE(Initialized = True);
  41.         IViewRect(Start,Extent,TheWindow,TheEnclosure);
  42.     }
  43.  
  44.  
  45. void            CEnclosure::DoMouseDown(MyEventRec Event)
  46.     {
  47.         CViewRect*    Thang;
  48.         LongPoint        WindowLocalMouseLoc;
  49.  
  50.         ERROR(Initialized != True,PRERR(ForceAbort,
  51.             "CEnclosure::DoMouseDown called on uninitialized object."));
  52.         ERROR(ListOfObjects==NIL,PRERR(ForceAbort,"CEnclosure ListOfObjects is NIL."));
  53.         WindowLocalMouseLoc.x = Event.Where.x - Window->Start.x;
  54.         WindowLocalMouseLoc.y = Event.Where.y - Window->Start.y;
  55.         ListOfObjects->ResetScan();
  56.         while (ListOfObjects->GetNext(&Thang))
  57.             {
  58.                 /* if click in object then send it */
  59.                 if (LongPtInRect(WindowLocalMouseLoc,LongPointOf(Thang->Origin.x,
  60.                     Thang->Origin.y),Thang->Extent) && Thang->Enabled)
  61.                     {
  62.                         LastMouseDownViewRect = Thang;
  63.                         Thang->DoMouseDown(Event);
  64.                         return; /* successful dispatch */
  65.                     }
  66.             }
  67.         LastMouseDownViewRect = NIL;  /* no mouse down */
  68.     }
  69.  
  70.  
  71. MyBoolean    CEnclosure::DoKeyDown(MyEventRec Event)
  72.     {
  73.         CViewRect*        Thang;
  74.  
  75.         ERROR(Initialized != True,PRERR(ForceAbort,
  76.             "CEnclosure::DoKeyDown called on uninitialized object."));
  77.         ERROR(ListOfObjects==NIL,PRERR(ForceAbort,"CEnclosure ListOfObjects is NIL."));
  78.         ListOfObjects->ResetScan();
  79.         while (ListOfObjects->GetNext(&Thang))
  80.             {
  81.                 if (Thang->Enabled)
  82.                     {
  83.                         if (Thang->DoKeyDown(Event))
  84.                             {
  85.                                 LastKeyDownViewRect = Thang;
  86.                                 return;
  87.                             }
  88.                     }
  89.             }
  90.         LastKeyDownViewRect = NIL;
  91.     }
  92.  
  93.  
  94. MyBoolean    CEnclosure::DoMouseMoved(MyEventRec Event)
  95.     {
  96.         CViewRect*    Thang;
  97.         LongPoint        WindowLocalMouseLoc;
  98.  
  99.         ERROR(Initialized != True,PRERR(ForceAbort,
  100.             "CEnclosure::DoMouseMoved called on uninitialized object."));
  101.         ERROR(ListOfObjects==NIL,PRERR(ForceAbort,"CEnclosure ListOfObjects is NIL."));
  102.         WindowLocalMouseLoc.x = Event.Where.x - Window->Start.x;
  103.         WindowLocalMouseLoc.y = Event.Where.y - Window->Start.y;
  104.         ListOfObjects->ResetScan();
  105.         while (ListOfObjects->GetNext(&Thang))
  106.             {
  107.                 /* if click in object then send it */
  108.                 if (LongPtInRect(WindowLocalMouseLoc,LongPointOf(Thang->Origin.x,
  109.                     Thang->Origin.y),Thang->Extent) && Thang->Enabled)
  110.                     {
  111.                         if (Thang->DoMouseMoved(Event))
  112.                             {
  113.                                 return True; /* successful dispatch */
  114.                             }
  115.                     }
  116.             }
  117.         return False;
  118.     }
  119.  
  120.  
  121. void            CEnclosure::RecalcLocations(LongPoint EnclosureVisRectStart,
  122.                         LongPoint EnclosureVisRectExtent, LongPoint EnclosureOrigin)
  123.     {
  124.         CViewRect*    Thang;
  125.  
  126.         ERROR(Initialized != True,PRERR(ForceAbort,
  127.             "CEnclosure::RecalcLocations called on uninitialized object."));
  128.         ERROR(ListOfObjects==NIL,PRERR(ForceAbort,"CEnclosure ListOfObjects is NIL."));
  129.         inherited::RecalcLocations(EnclosureVisRectStart,EnclosureVisRectExtent,
  130.             EnclosureOrigin);
  131.         ListOfObjects->ResetScan();
  132.         while (ListOfObjects->GetNext(&Thang))
  133.             {
  134.                 Thang->RecalcLocations(VisRectStart,VisRectExtent,Origin);
  135.             }
  136.     }
  137.  
  138.  
  139. void            CEnclosure::DoUpdate(void)
  140.     {
  141.         CViewRect*    Thang;
  142.  
  143.         ERROR(Initialized != True,PRERR(ForceAbort,
  144.             "CEnclosure::DoUpdate called on uninitialized object."));
  145.         ERROR(ListOfObjects==NIL,PRERR(ForceAbort,"CEnclosure ListOfObjects is NIL."));
  146.         ListOfObjects->ResetScan();
  147.         while (ListOfObjects->GetNext(&Thang))
  148.             {
  149.                 Window->SetOrigin(ZeroPoint);
  150.                 if (Window->RectVisible(Thang->VisRectStart,Thang->VisRectExtent))
  151.                     {
  152.                         Thang->DoUpdate(); /* send update to each visible object */
  153.                     }
  154.             }
  155.     }
  156.  
  157.  
  158. void            CEnclosure::DoResume(void)
  159.     {
  160.         CViewRect*    Thang;
  161.  
  162.         ERROR(Initialized != True,PRERR(ForceAbort,
  163.             "CEnclosure::DoResume called on uninitialized object."));
  164.         ERROR(ListOfObjects==NIL,PRERR(ForceAbort,"CEnclosure ListOfObjects is NIL."));
  165.         ListOfObjects->ResetScan();
  166.         while (ListOfObjects->GetNext(&Thang))
  167.             {
  168.                 Thang->DoResume();  /* go back into working order */
  169.             }
  170.         inherited::DoResume();
  171.     }
  172.  
  173.  
  174. void            CEnclosure::DoSuspend(void)
  175.     {
  176.         CViewRect*    Thang;
  177.  
  178.         ERROR(Initialized != True,PRERR(ForceAbort,
  179.             "CEnclosure::DoSuspend called on uninitialized object."));
  180.         ERROR(ListOfObjects==NIL,PRERR(ForceAbort,"CEnclosure ListOfObjects is NIL."));
  181.         ListOfObjects->ResetScan();
  182.         while (ListOfObjects->GetNext(&Thang))
  183.             {
  184.                 Thang->DoSuspend();  /* go to suspended mode */
  185.             }
  186.         inherited::DoSuspend();
  187.     }
  188.  
  189.  
  190. MyBoolean    CEnclosure::DoMenuCommand(ushort MenuCommandValue)
  191.     {
  192.         CViewRect*    Thang;
  193.  
  194.         ERROR(Initialized != True,PRERR(ForceAbort,
  195.             "CEnclosure::DoMenuCommand called on uninitialized object."));
  196.         ERROR(ListOfObjects==NIL,PRERR(ForceAbort,"CEnclosure ListOfObjects is NIL."));
  197.         ListOfObjects->ResetScan();
  198.         while (ListOfObjects->GetNext(&Thang))
  199.             {
  200.                 if (Thang->Enabled)
  201.                     {
  202.                         if (Thang->DoMenuCommand(MenuCommandValue))
  203.                             {
  204.                                 return True;
  205.                             }
  206.                     }
  207.             }
  208.         return False;
  209.     }
  210.  
  211.  
  212. void            CEnclosure::RegisterViewRect(CViewRect* TheViewRect)
  213.     {
  214.         ERROR(Initialized != True,PRERR(ForceAbort,
  215.             "CEnclosure::RegisterViewRect called on uninitialized object."));
  216.         ERROR(ListOfObjects==NIL,PRERR(ForceAbort,"CEnclosure ListOfObjects is NIL."));
  217.         ListOfObjects->PushElement(&TheViewRect);
  218.     }
  219.  
  220.  
  221. void            CEnclosure::DeregisterViewRect(CViewRect* TheViewRect)
  222.     {
  223.         ERROR(Initialized != True,PRERR(ForceAbort,
  224.             "CEnclosure::DeregisterViewRect called on uninitialized object."));
  225.         ERROR(ListOfObjects==NIL,PRERR(ForceAbort,"CEnclosure ListOfObjects is NIL."));
  226.         ListOfObjects->KillElement(&TheViewRect);
  227.     }
  228.  
  229.  
  230. void            CEnclosure::EnableMenuItems(void)
  231.     {
  232.         CViewRect*    Thang;
  233.  
  234.         ERROR(Initialized != True,PRERR(ForceAbort,
  235.             "CEnclosure::EnableMenuItems called on uninitialized object."));
  236.         ERROR(ListOfObjects==NIL,PRERR(ForceAbort,"CEnclosure ListOfObjects is NIL."));
  237.         ListOfObjects->ResetScan();
  238.         while (ListOfObjects->GetNext(&Thang))
  239.             {
  240.                 if (Thang->Enabled)
  241.                     {
  242.                         Thang->EnableMenuItems();
  243.                     }
  244.             }
  245.     }
  246.  
  247.  
  248. void            CEnclosure::DoEnclosureResized(LongPoint EnclosureExtentAdjust)
  249.     {
  250.         CViewRect*        Thang;
  251.         LongPoint            MyOldExtent;
  252.  
  253.         ERROR(Initialized != True,PRERR(ForceAbort,
  254.             "CEnclosure::DoEnclosureResized called on uninitialized object."));
  255.         MyOldExtent = Extent;
  256.         inherited::DoEnclosureResized(EnclosureExtentAdjust);
  257.         ERROR(ListOfObjects==NIL,PRERR(ForceAbort,"CEnclosure ListOfObjects is NIL."));
  258.         ListOfObjects->ResetScan();
  259.         while (ListOfObjects->GetNext(&Thang))
  260.             {
  261.                 Thang->DoEnclosureResized(MyOldExtent);
  262.             }
  263.     }
  264.